//微信系统信息获取的js
let en_js = require('/environment.js');

//保存购物车信息
function saveSystemInfo(info) {
  wx.setStorageSync(en_js.systemInfoKey, info);
}

//获取用户信息
function systemInfo() {
  let value = wx.getStorageSync(en_js.systemInfoKey);
  if (value) {
    return value;
  } else {
    return null;
  }
}

function navInfo() {
  let value = wx.getStorageSync(en_js.systemInfoKey);
  let statusBarHeight = value.statusBarHeight;
  let roudRect = wx.getMenuButtonBoundingClientRect();
  let navBarHeight = (roudRect.top - statusBarHeight) * 2 + roudRect.height;
  return {
    statusBarHeight: statusBarHeight,
    navBarHeight: navBarHeight
  }
}

module.exports = {
  saveSystemInfo: saveSystemInfo,
  systemInfo: systemInfo,
  navInfo: navInfo
}